package servlet;
import servlet.Connections;
import java.sql.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class DeveloperFormSubmit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	Connections conn=new Connections();
	PreparedStatement pstmt=null;
	String query,address,name,phone,email,ack,nack,id;
	int updateStatement=0;
	
	protected void doGett(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		try
		{
			PrintWriter out=response.getWriter();
			
			query="INSERT INTO Developer(Developer_Name ,Phone  ,E_Mail ,Developer_Address)VALUES(?,?,?,?)";
		
			name=request.getParameter("DevNametxt");
			phone=request.getParameter("DevPhonetxt");
			email=request.getParameter("DevEmailtxt");
			address=request.getParameter("DevAddrta");
		
			pstmt=conn.getConnection().prepareStatement(query);
			pstmt.setString(1,name);
			pstmt.setString(2,phone);
			pstmt.setString(3,email);
			pstmt.setString(4,address);
			updateStatement=pstmt.executeUpdate();
			
			if (updateStatement!=0)
				{
					out.println("Data Inserted Succesfully");
					response.sendRedirect("AddDeveloper.jsp");
				}
			else
					out.println("Data Not Saved");
		
		}
	catch(Exception e)
		{
			e.printStackTrace();
		}
		
	}	
}  
